<?php
/**
 * IMMOPHP
 * ADMINISTRATION 
 * GESTION DES TYPES D ANNONCES
 * http://www.immophp.fr
 * **/
require 'kernel/common.php';

if(!$Session->check_admin()) redirect('index.php');

if(isset($_POST['add_type'])) Anonce::ajout_type();
if(isset($_GET['delete'])) Anonce::delete_type();
if(isset($_POST['edition_type'])) Anonce::edition_type();
if(isset($_GET['add_menu'])) Anonce::ajout_menu_type();

$template->set_filenames(array('type' => 'template/type.tpl'));

$Sql = $db->sql_query("SELECT * FROM immo_annonce_type ORDER BY nom");

while($Type = $db->sql_fetcharray($Sql))
{
    $action = '';
    
    $action .= '<a href="type.php?add_menu&amp;type_id='.$Type['id'].'&amp;token='.$_SESSION['token'].'" title=""><img src="images/add_menu.png" alt="" style="border:none; height:20px; width:20px;"/></a>';
    $action .= '&nbsp;&nbsp;&nbsp;<a href="type_edition.php?type='.$Type['id'].'" title=""><img src="images/edit.png" alt="" style="border:none; height:20px; width:20px;"/></a>';
    $action .= '&nbsp;&nbsp;&nbsp;<a href="javascript:deltype(\'' . $Type['id'] . '\');"><img src="images/del.png" style="border:none; width:20px; height:20px;" /></a>';    
    $template->assign_block_vars('type', array(
    'V_ID'  =>  $Type['id'],
    'V_NOM' =>  parse_simple($Type['nom']),
    'V_ACTION'  =>  $action,
    'V_VISIBLE' =>  $Type['visible'] == 1 ? $lang['Oui'] : $lang['Non'],
    ));
}

$template->assign_vars(array(
'L_TYPE'    =>  $lang['Type'],
'L_NOUVEAU_TYPE'    =>  $lang['Nouveau_type'],
'L_NOM' =>  $lang['Nom'],
'L_ENREGISTRER' =>  $lang['Enregistrer'],
'L_DESCRIPTION' =>  $lang['Description'],
'L_ACTION'  =>  $lang['Action'],
'L_NOUVEAU' =>  $lang['Nouveau'],
'L_VISIBLE' =>  $lang['Visible'],
'L_OUI' =>  $lang['Oui'],
'L_NON' =>  $lang['Non'],
'L_CONFIRM_SUPPRESSION_TYPE'    =>  $lang['Confirm_supprime_type'],
'L_AJOUTER_AU_MENU' =>  $lang['Ajouter_au_menu'],
'V_TOKEN'   =>  $_SESSION['token'],
));
$template->display('type');
require 'footer.php';
?>

